using System;
using CStock;
using CUtil;
using System.Diagnostics;
using System.ComponentModel;

namespace CStock
{
	
	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
    public class TradeEconomyProfile : TradeSystem , ITradeEconomyProfile  
    {


        
        
        private int number_Shares;
        private int number_Bonds;
      
        private DateTime date_Start;


        System.Collections.ArrayList economyStatusCollection;


        private System.Collections.Specialized.StringCollection portfolioNames;


        public TradeEconomyProfile()
        {
            ResetPathFromConfiguration();

        }
       
        public override bool ResetPathFromConfiguration()
        {

            ProgramContext pc = ProgramContext.Instance;
            Debug.Assert(pc != null);
            if (pc != null)
                this.path = pc.Configuration.Directories.TradeEconomyProfilePath;
            return true;

        }
        public override bool Serialize()
        {
            ResetPathFromConfiguration();
            return base.Serialize();
        }
       
        /// <summary>
        /// to set it only for deserialization
        /// </summary>
        [Category("Economy\\Trade"), DescriptionAttribute("int")]
        public int Number_Shares
        {
            get
            {
                return this.number_Shares;
            }
            set
            {
                this.number_Shares = value;
            }
        }
        
        /// <summary>
        /// to set it only for deserialization
        /// </summary>
        [Category("Economy\\Trade"), DescriptionAttribute("int")]
        public int Number_Bonds
        {
            get
            {
                return this.number_Bonds;
            }
            set
            {
                this.number_Bonds = value;
            }
        }
      
        /// <summary>
        /// to set it only for deserialization
        /// </summary>
        [Category("Economy\\Trade"), DescriptionAttribute("DateTime")]
        public DateTime Date_Start
        {
            get
            {
                return this.date_Start;
            }
            set
            {
                this.date_Start = value;
            }
        }

        

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public System.Collections.ArrayList EconomyStatusCollection
        {
            get
            {
                return this.economyStatusCollection;
            }
            set
            {
                economyStatusCollection = value;
            }
        }

         [System.Xml.Serialization.XmlIgnoreAttribute()]
        public System.Collections.Specialized.StringCollection PortfolioNames
        {
            get
            {
                return portfolioNames;
            }
            set
            {
                portfolioNames = value;
            }
        }

       
        public EconomyStatus[] EconomyStatusArray
        {
            get
            {


                if (this.economyStatusCollection != null)
                {
                    //System.Collections.ArrayList arrL = new System.Collections.ArrayList();
                    return (EconomyStatus[])economyStatusCollection.ToArray(typeof(EconomyStatus));
                }
                
                return null;
            }
            set
            {

                economyStatusCollection = new System.Collections.ArrayList();
                for (int i = 0; i < value.Length; i++)
                {
                    EconomyStatus q = value[i] as EconomyStatus;

                    this.economyStatusCollection.Add(q);

                }

            }
        }
        public string[] PortfolioNamesArray
        {
            get
            {

                
                if (this.portfolioNames != null)
                {
                    System.Collections.ArrayList arrL = new System.Collections.ArrayList();
                    for (int i = 0; i < this.portfolioNames.Count; i++)
                    {
                        arrL.Add(this.portfolioNames[i]);
                    }
                    if (arrL != null)
                        return (string[])arrL.ToArray(typeof(string));
                }
                
                return null;
            }
            set
            {

                this.portfolioNames = new System.Collections.Specialized.StringCollection();
                for (int i = 0; i < value.Length; i++)
                {
                    string q = value[i] as string;

                    this.portfolioNames.Add(q);

                }

            }
        }
       
     
  
    }
}
